package org.javia.arity;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.mockito.Mockito.*;

public class SymbolTest {

	Symbol s;
	Symbol s2;
	Symbol s3;
	@Before
	public void setUp() throws Exception {
		s= new Symbol("symbol1", 1.0, 2.0, true);
		s2= new Symbol("symbol2", 3.0, false);
		Function f= mock(Function.class);
		s3= new Symbol("function", f);
		
		
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testHashCode() {
		assertEquals(-1743438442,s.hashCode());
	}



	@Test
	public void testMakeArg() {
		Symbol arg=Symbol.makeArg("uno", 1);
		assertEquals(0,arg.getArity());
		assertEquals("uno",arg.getName());
		
	}

	@Test
	public void testMakeVmOp() {
		Symbol arg=Symbol.makeVmOp("uno", 1);
		assertEquals(0,arg.getArity());
		assertEquals("uno",arg.getName());
	}

	@Test
	public void testToString() {
		assertEquals("Symbol 'symbol1' arity -3 val 1.0 op 0",s.toString());
	}

	@Test
	public void testGetName() {
		assertEquals("symbol1",s.getName());
	}

	@Test
	public void testGetArity() {
		assertEquals(0,s.getArity());
	}

	@Test
	public void testNewEmpty() {
		Symbol em= Symbol.newEmpty(s);
		assertEquals(s.getName(),em.getName());
		assertEquals(s.getArity(),em.getArity());
	}

	@Test
	public void testIsEmpty() {
		assertFalse(s.isEmpty());
		Symbol s1= mock(Symbol.class);
		s1.op=0;
		s1.fun=null;
		s1.valueIm=0;
		s1.valueRe=0;
		s1= Symbol.newEmpty(s1);
		assertTrue(s1.isEmpty());
	}

	@Test
	public void testSetKey() {
		s.setKey("new", 1);
		assertEquals("new",s.getName());
		assertEquals(1,s.getArity());
	}

	@Test
	public void testEqualsObject() {
	//	fail("Not yet implemented");
	}

}
